<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>登陆--首页</title>
<!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script src="libs/d3.v3.min.js"></script>
<script src="libs/nv.d3.min.css"></script>
<script src="libs/nv.d3.min.js"></script>

</head>
<body>
	<div class="container">
		<div class="row">
			<div class="page-header">
				<h2>
					<strong>小超记账</strong>
				</h2>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-8">
				<ul class="nav nav-pills">
					<li role="presentation"><a href="index.html">首页</a></li>

					<li role="presentation"><a href="adda.html">添加档案</a></li>
					<li role="presentation" class="active"><a href="query.html">查询</a></li>
					<li><a href="#">用户： <span id="text3"> </span>
					</a></li>
				</ul>
				<div class="col-md-4" id="search-box-archive"></div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<hr />
			</div>
		</div>
	</div>
	<div class="containner">
		<div class="row">
			<div class="col-md-12">

				<hr />
			</div>
		</div>
	</div>





	<div class="container">
		<div class="row">
			<div class="col-md-4">
				<div class="panel panel-primary">
					<div class="panel-heading">当月支出</div>
					<div class="panel-body">
						<h1 id="text5"></h1>
					</div>
				</div>
			</div>
			<div class="container">
				<div class="row">
					<div class="col-md-4">
						<div class="panel panel-primary">
							<div class="panel-heading">当月收入</div>
							<div class="panel-body">
								<h1 id="text4"></h1>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<div class="panel panel-warning">
							<div class="panel-heading">每个类别平均</div>
							<div class="panel-body" id="list2"></div>
						</div>
					</div>
					<div class="row">
						<div class="col-md-12">
							<div class="panel panel-warning">
								<div class="panel-heading">每个类别和</div>
								<div class="panel-body" id="list3"></div>
							</div>
						</div>
						<div class="container">
							<div class="row">
								<div class="col-md-12" id="chart">
									<p class="text-center">
										<br />
									<hr />
									<strong>平均支出使用统计</strong>
									<svg style="height: 480px; width: 100%"></svg>
									</br>
									</p>
								</div>
							</div>
						</div>
						<div class="container">
							<div class="row">
								<div class="col-md-12" id="chart1">
									<p class="text-center">
										<br />
									<hr />
									<strong>平均收入使用统计</strong>
									<svg style="height: 480px; width: 100%"></svg>
									</br>
									</p>
								</div>
							</div>
						</div>
						<div class="container">
							<div class="row">
								<div class="col-md-12" id="chart2">
									<p class="text-center">
										<br />
									<hr />
									<strong>支出和使用统计</strong>
									<svg style="height: 480px; width: 100%"></svg>
									</br>
									</p>
								</div>
							</div>
						</div>
						<div class="container">
							<div class="row">
								<div class="col-md-12" id="chart3">
									<p class="text-center">
										<br />
									<hr />
									<strong>收入和使用统计</strong>
									<svg style="height: 480px; width: 100%"></svg>
									</br>
									</p>
								</div>
							</div>
						</div>




						<script type="text/javascript">
							$(function() {
								$.getJSON('query_p.action', function(res) {
									console.log(res);
									$('#text5').text(res.s);
								});
								$.getJSON('query_p.action', function(res) {
									console.log(res);
									$('#text4').text(res.z);
								});
								$.getJSON('query_o.action', function(res) {
									console.log(res);
									var data = {
										'item' : res
									};
									var t = Handlebars.compile($('#template')
											.html());
									$('#list2').html(t(data));
								});
								$.getJSON('query_u.action', function(res) {
									console.log(res);
									var data = {
										'item' : res
									};
									var t = Handlebars.compile($('#template')
											.html());
									$('#list3').html(t(data));
								});
								$.getJSON('query_u.action', function(res) {
									nv.addGraph(function() {
										var chart = nv.models.pieChart().x(
												function(d) {
													return d.kind
												}).y(function(d) {
											return d.s
										}).showLabels(true)
												.labelType('percent');
										d3.select('#chart svg').datum(res)
												.transition().duration(350)
												.call(chart);
										return chart;

									});
								});
								$.getJSON('query_u.action', function(res) {
									nv.addGraph(function() {
										var chart1 = nv.models.pieChart().x(
												function(d) {
													return d.kind
												}).y(function(d) {
											return d.z
										}).showLabels(true)
												.labelType('percent');
										d3.select('#chart1 svg').datum(res)
												.transition().duration(350)
												.call(chart1);
										return chart1;

									});
								});
								$.getJSON('query_o.action', function(res) {
									nv.addGraph(function() {
										var chart2 = nv.models.pieChart().x(
												function(d) {
													return d.kind
												}).y(function(d) {
											return d.s
										}).showLabels(true)
												.labelType('percent');
										d3.select('#chart2 svg').datum(res)
												.transition().duration(350)
												.call(chart2);
										return chart2;

									});
								});
								$.getJSON('query_o.action', function(res) {
									nv.addGraph(function() {
										var chart3 = nv.models.pieChart().x(
												function(d) {
													return d.kind
												}).y(function(d) {
											return d.s

										}).showLabels(true)
												.labelType('percent');
										d3.select('#chart3 svg').datum(res)
												.transition().duration(350)
												.call(chart3);
										return chart3;

									});
								});

							});
						</script>

						<script type="text/javascript" src="libs/handlebars.min.js"></script>
						<script id="template" type="text/x-handlebars-template">
	{{#each item}}
		<div class="panel panel-default col-md-3">
			<div class="panel-body">
				<dl>
					<dt>支出</dt><dd>{{s}}</dd>
					<dt>收入</dt><dd>{{z}}</dd>
					<dt>类别</dt><dd>{{kind}}</dd>
				</dl>
			</div>
		</div>
	{{/each}}
</script>
</body>
</html>